<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>嵌套循环</title>
    <style>
        span{
            display: inline-block;
            width: 60px;
            
        }
    </style>
    <script>
        /* 
            打印一个5*5的矩阵，矩阵元素为*
        
        */
       for(r=1;r<=5;r++){
            for(i=1;i<=5;i++){
                document.write('*&nbsp')
            }
            document.write('<br>')
       }

document.write("<hr>")

       for(r=1;r<=5;r++){
            for(i=1;i<=r;i++){
                document.write('*&nbsp')
            }
            document.write('<br>')
       }

document.write("<hr>")

        for(r=1;r<=5;r++){
            for(i=1;i<=6-r;i++){
                document.write('*&nbsp')
            }
            document.write('<br>')
       }  

document.write("<hr>")

       for(i=1;i<10;i++){
            for(j=1;j<=i;j++){
                document.write(`<span>${j}*${i}=${i*j}</span>`)
            }
            document.write('<br>')
       }

document.write("<hr>")
       /* 
            当循环发生嵌套时，外层循环执行一次，内层循环执行一轮
       
       */

       
    </script>

</head>
<body>
    
</body>
</html>